
import { PageHeader } from "@/components/page-header";
import { Button } from "@/components/base";
import * as hooks from "../../hooks";
import { useNavigate } from "react-router-dom";

export interface IHeaderProps {
    onSave: () => void;
}

export function Header({ onSave }: IHeaderProps) {

    const { isEdit } = hooks.useSearch();
    const navigate = useNavigate();

    return (
        <PageHeader
            title={isEdit ? "编辑客户" : "新增客户"}
            onBack={() => navigate(-1)}
            extra={
                <Button
                    size='small'
                    color='primary'
                    onClick={onSave}
                >
                    {isEdit ? "保存" : "新增"}
                </Button>
            }
        />
    );
}
